
clear all
set more off
global dir "C:\code"
global dir2 "C:\code\output" 



******************************************************************************
******************************** Main Tables  ********************************
******************************************************************************


**********************************************************************************
********** Table 1: Sample summary and comparison ********************************

cd "$dir"
use Pseudodata_main.dta, clear
cd "$dir2"

estpost tabstat purchases_total n_transaction debt_total amtpaid interest penalty percent_paid paid_below_min paid_below50 utilisation credit_limit age male married educ_num investment personal_loan, ///
statistics(mean sd min max) columns(statistics)
esttab, cells("mean(fmt(2)) sd(fmt(2)) min(fmt(0)) max(fmt(0))") nomtitle nonumber noobs title(Table 1: Descriptive Statistics)
esttab using table1.csv, replace cells("mean(fmt(2)) sd(fmt(2)) min(fmt(0)) max(fmt(0))") nomtitle nonumber noobs title(Table 1: Descriptive Statistics)
eststo clear


estpost tabstat purchases_total n_transaction debt_total amtpaid interest penalty percent_paid paid_below_min paid_below50 utilisation credit_limit age male married educ_num investment personal_loan if treat_all_an==1 | treat_2_new_an==1, ///
statistics(mean sd min max) columns(statistics)
esttab, cells("mean(fmt(2)) sd(fmt(2)) min(fmt(0)) max(fmt(0))") nomtitle nonumber noobs title(Table 1: Descriptive Statistics)
esttab using table1_treat.csv, replace cells("mean(fmt(2)) sd(fmt(2)) min(fmt(0)) max(fmt(0))") nomtitle nonumber noobs title(Table 1: Descriptive Statistics)
eststo clear



estpost tabstat purchases_total n_transaction debt_total amtpaid interest penalty percent_paid paid_below_min paid_below50 utilisation credit_limit age male married educ_num investment personal_loan if treat_all_an==0 & treat_2_new_an==0, ///
statistics(mean sd min max) columns(statistics)
esttab, cells("mean(fmt(2)) sd(fmt(2)) min(fmt(0)) max(fmt(0))") nomtitle nonumber noobs title(Table 1: Descriptive Statistics)
esttab using table1_control.csv, replace cells("mean(fmt(2)) sd(fmt(2)) min(fmt(0)) max(fmt(0))") nomtitle nonumber noobs title(Table 1: Descriptive Statistics)
eststo clear


**********************************************************************************
********** Table 2: Persistence in payment behavior ********************************

*Panel A: Percentage payment transition matrix for the year 2010
preserve
keep if yearmth==tm(2010m12)
bys paid_bin_6m: sum paid_bin1 paid_bin2 paid_bin3 paid_bin4 paid_bin5
restore

*Panel B: Persistence in payment below and above the minimum payment in 2010
forvalues k=1/6 {
bys paid_below`k': sum prob_below`k'
ttest prob_below`k', by(paid_below`k')

}


*************************************************************************************
**** Table 3: Spending and debt response to the policy announcement *****************

	foreach var in purchases_total debt_total percent_paid interest penalty {
  eststo: quietly reghdfe `var' treat_2_new_an_post treat_all_an_post , absorb(custid yearmth) vce(cluster city_num#card_type)
 
	}
	
   esttab, b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label  mtitles("Spending" "Debt"  "% Paid" "Interest" "Penalty" )
   esttab using table3_panelA.csv, replace b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label  mtitles("Spending" "Debt"  "% Paid" "Interest" "Penalty" )
   eststo clear

   
foreach var in purchases_total debt_total percent_paid interest penalty {
  eststo: quietly reghdfe `var'  treat_2_new_an_post treat_all_an_0m_post treat_all_an_6m_post treat_all_an_12m_post treat_all_an_18m_post treat_all_an_24m_post , absorb(custid yearmth) vce(cluster city_num#card_type)
 
	}
   esttab, b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label  mtitles("Spending" "Debt"  "% Paid" "Interest" "Penalty" )
   esttab using table3_panelB.csv, replace b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label  mtitles("Spending" "Debt"  "% Paid" "Interest" "Penalty" )
   eststo clear
   
  
***************************************************************************************************
*****************Table 4: Using new credit cards as the control group******************************
cd "$dir"
use Pseudodata_newcard.dta, clear
cd "$dir2"

estpost tabstat purchases_total n_transaction debt_total amtpaid interest penalty percent_paid paid_below_min paid_below50 utilisation credit_limit age male married educ_num, ///
statistics(mean sd min max) columns(statistics)

esttab, cells("mean(fmt(2)) sd(fmt(2)) min(fmt(0)) max(fmt(0))") nomtitle nonumber noobs 
esttab using table4_sumstat_newcard.csv, replace cells("mean(fmt(2)) sd(fmt(2)) min(fmt(0)) max(fmt(0))") nomtitle nonumber noobs

cd "$dir"
use Pseudodata_MP_newcard.dta, clear
cd "$dir2"


foreach var in purchases_total debt_total percent_paid interest penalty {
  eststo: quietly reghdfe `var' treat_12m_post treat_18m_post treat_24m_post , absorb(custid yearmth) vce(cluster city_num#card_type) 
	}
	
   esttab, b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label  mtitles("Spending" "Debt"  "% Paid" "Interest" "Penalty" )
   esttab using table4_MP_newcard.csv, replace b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label  mtitles("Spending" "Debt"  "% Paid" "Interest" "Penalty" )
   eststo clear
   
 


**************************************************************************************************
*************Table 5: New credit cards – a reduction in the minimum payment***********************
cd "$dir"
use Pseudodata_newcard.dta, clear
cd "$dir2"
	foreach var in purchases_total debt_total percent_paid interest penalty{
  eststo: quietly reghdfe `var' treat_reduce_post, absorb(custid yearmth) vce(cluster city_num#card_type)
 
	}
	
   esttab, b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label keep (treat_reduce_post) mtitles("Spending" "Debt"  "% Paid" "Interest" "Penalty") 
   esttab using table5_newcard.csv, replace b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label keep (treat_reduce_post) mtitles("Spending" "Debt"  "% Paid" "Interest" "Penalty") 
 
   eststo clear


    
***************************************************************************************************
*********************** Table 6: Changes in the delinquency rate***********************************



cd "$dir"
use Pseudodata_main.dta, clear
cd "$dir2"

foreach var in delinquent30 delinquent60 {
  eststo: quietly reghdfe `var' treat_2_new_an_post treat_all_an_post , absorb(custid yearmth) vce(cluster city_num#card_type)  
	}
   esttab, b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label   mtitles("Delinquent30" "Delinquent60")  

   
  foreach var in delinquent30 delinquent60{
  eststo: quietly reghdfe `var' treat_2_new_an_post treat_all_an_0m_post treat_all_an_6m_post treat_all_an_12m_post treat_all_an_18m_post treat_all_an_24m_post  , absorb(custid yearmth) vce(cluster city_num#card_type)
	}

   esttab, b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label  mtitles("Delinquent30" "Delinquent60" "Delinquent30" "Delinquent60")  
   esttab using table6_delinquent.csv, replace b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label   mtitles("Delinquent30" "Delinquent60" "Delinquent30" "Delinquent60")  
   eststo clear
   

************************************************************************************************************
**** Table 7: Alternative Treatment Based on Credit Card Limit *********************************************
 
 foreach var in purchases_total debt_total delinquent60 {
  eststo: quietly reghdfe `var' treat_limit_post , absorb(custid yearmth) vce(cluster city_num#card_type)
 
	}
	
   esttab, b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label  mtitles("Spending" "Debt" "Delinquent60")
   esttab using table7_credit_limit.csv, replace b(4) se(4) ar2 star(* 0.1 ** 0.05 *** 0.01) label  mtitles("Spending" "Debt" "Delinquent60")
 
   eststo clear

   
   
   